//发送普通短信
function send(tbl){
	var phone=tbl.phone
	//验证输入内容是否为手机号码
	if(!(/^1[1-9][0-9]\d{8}$/.test(phone))){
		return -2;
	}
	var message =tbl.text;
	message += conf.get("smd.text");
	message = java.net.URLEncoder.encode(message, "GBK");  
	var url = new String("inolink.com/WS/BatchSend.aspx?CorpID="+conf.get("sms.id")+"&Pwd="+conf.get("sms.pwd")+"&Mobile="+phone+"&Content=" + message);
//	url = new String(url.getBytes(),"gbk");
	print(url)
	var res = Http.get(url);
	return res;
}
function reg(tbl){
	let code=""; 
	for(var i=0;i<6;i++) 
	{ 
		code+=Math.floor(Math.random()*10); 
	} 
	tbl.put("text","你在"+Times.format(new java.util.Date())+"注册心教育账号,验证码是:"+code)
	try {
		print(tbl)
		let res= send(tbl)
		if(res==-2){
			return {status:res,msg:"手机号错误"};
		}
		return {status:1,msg:"success",code:code};
	} catch (e) {
		print(e)
	}
	return {msg:"faile",status:-3};
}
function forget(tbl){
	let code=""; 
	for(var i=0;i<6;i++) 
	{ 
		code+=Math.floor(Math.random()*10); 
	} 
	tbl.put("text","你在"+Times.format(new java.util.Date())+"点击找回心教育账号密码,验证码是:"+code)
	try {
		print(tbl)
		let res= send(tbl)
		if(res==-2){
			return {status:res,msg:"手机号错误"};
		}
		return {status:1,msg:"success",code:code};
	} catch (e) {
		print(e)
	}
	return {msg:"faile",status:-3};
}